﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TakePhotoTogether.Communication.Protocols
{
    /// <summary>
    /// Messages to handle Distributed Locking service
    /// </summary>
    public enum LockingMessage
    {
        Request = 1,
        Accepted_Request = 2,
        Denied_Request = 3,
        Release = 4,
        ACK = 5
    }

    /// <summary>
    /// Protocol to handle Distributed Locking service (aka RemoteSemaphore)
    /// </summary>
    public class LockingData : PayloadData
    {
        public LockingMessage Message
        {
            get; private set;
        }

        public LockingData(LockingMessage message)
        {
            Message = message;
        }

        public LockingData(byte[] data)
        {
            Message = (LockingMessage)((int)data[0]);
        }

        public byte[] ToBytes()
        {
            byte[] data = new byte[]
            {
                (byte)((int)Message)
            };

            return data;
        }
    }
}
